<template>
  <div>
      <h2 class="live-title">直播拍卖</h2>
      <video-player class="vjs-custom-skin"
                    :options="playerOptions"
                    :playsinline="true"
                    @ready="playerReadied"
                    ref="videoPlayer"
      >
      </video-player>


  </div>
</template>

<script>
  import 'vue-video-player/src/custom-theme.css'
  import videojs from 'video.js';
  window.videojs = videojs;
  require('videojs-contrib-hls/dist/videojs-contrib-hls.js');
  export default {
    name: "liveAuction",
    data(){
      return {
        playerOptions: {
          // videojs and plugin options
          language: 'zh-CN',
          autoplay: false,
          live: true,
          preload:'none',
          playsinline:false,
          aspectRatio: '4:3', // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
          fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
          height: '270',
          width:'360',
          // width: document.documentElement.clientWidth,
          isFullscreen:false,
          sources: [{
            withCredentials: false,
            type: "application/x-mpegURL",
            // src: "https://logos-channel.scaleengine.net/logos-channel/live/biblescreen-ad-free/playlist.m3u8"
            src:"http://59.175.137.107:10080/hls/wangjz/wangjz_live.m3u8",
          }],
          controlBar: {
            timeDivider: false,
            durationDisplay: false
          },
          flash: { hls: { withCredentials: false }},
          html5: { hls: { withCredentials: false }},
          poster: "../../../static/images/pro_1.png",
        }
      }
    },
    computed: {
      player() {
        return this.$refs.videoPlayer.player
      }
    },
    methods: {
      playerReadied(player) {
        var hls = player.tech({IWillNotUseThisInPlugins: true}).hls;
        player.tech_.hls.xhr.beforeRequest = function (options) {
          // console.log(options);
          return options
        }
      },
    }
  }
</script>

<style scoped>
  .live-title{
    text-align: center;
    line-height: 80px;
  }
</style>
